#include <bits/stdc++.h>
using namespace std;
int main()
{
    freopen("arena.in", "r", stdin);
    freopen("arena.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= 2 * n; i++)
    {
        int a;
        cin >> a;
    }
    int t;
    cin >> t;
    while (t--)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << a + b + c + d << endl;
    }
    return 0;
}
